package com.hzit.search.controller;

import com.hzit.search.service.ISearchService;
import com.hzit.search.vo.ItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.Map;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@Controller
@RequestMapping
public class SearchController {
	@Autowired
	private ISearchService searchService;

	@GetMapping({"/","/search.html"})
	public String search(Model model, ItemVo vo) throws IOException {
		//1. 根据条件查询出结果
		Map<String,Object> resultMap = searchService.search(vo);
		//2. 将查询结果放到model中
		model.addAttribute("resultMap",resultMap);
		model.addAttribute("vo",vo);
		return "search";
	}
}
